package org.i_plus.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.i_plus.model.TarotBean;
import org.i_plus.model.services.MemberService;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class TarotServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
				
		
				WebApplicationContext context =
				WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
				MemberService service = (MemberService)context.getBean("MemberService"); 
				
				String account = req.getParameter("account");
				TarotBean tarot = service.checkTarot(account);
				req.setAttribute("tarot", tarot);
				req.getRequestDispatcher("/View/Tarot.jsp").forward(req, resp);
				return;
	}

}
